﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using WebView.WSCCD;

namespace WebView.CCD {
	public partial class Default : System.Web.UI.Page {
		
		private CCDsServices t;
		
		protected void Page_Load(object sender, EventArgs e) {
			t = new CCDsServices();
			this.refreshGrid();
		}

		protected void Button1_Click(object sender, EventArgs e) {
			Panel1.Visible = false;
			Panel2.Visible = true;
		}

		protected void Button2_Click(object sender, EventArgs e) {
			uint id = uint.Parse(GridView1.SelectedDataKey.Value.ToString());
			t.remover(id);
			this.refreshGrid();
		}

		protected void Button3_Click(object sender, EventArgs e) {
			t.adicionar(TextBox1.Text, TextBox2.Text);
			Panel1.Visible = true;
			Panel2.Visible = false;
			this.refreshGrid();
		}

		protected void Button4_Click(object sender, EventArgs e) {
			Panel1.Visible = true;
			Panel2.Visible = false;
		}

		private void refreshGrid() {
			GridView1.DataSource = t.listar();
			GridView1.DataBind();
		}
	}
}
